//
//  YXClassRoomDetailsViewController.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/24.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXClassRoomDetailsViewController.h"
#import "YXClassRoomContentView.h"
#import "YXClassRoomModel.h"
@interface YXClassRoomDetailsViewController ()
@property (nonatomic ,strong) YXClassRoomContentView *contentView;
@end

@implementation YXClassRoomDetailsViewController

- (YXClassRoomContentView *)contentView {
    if (!_contentView) {
        _contentView = [[YXClassRoomContentView alloc] initWithFrame:self.view.bounds];
    }
    return _contentView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"课程详情";
    self.view.backgroundColor = [UIColor whiteColor];
    [self createLeftBarButtonItemWithImage:@"导航栏_002"];
    [self requestData];
}

- (void)requestData {
//    http://121.196.210.134:8082/test_mpos/wx/getClassroomByid.do?id=1
    NSString *urlStr = @"getClassroomByid.do";
    NSDictionary *parameter = @{@"id":self.ID};
    [BX_NetWorkManager requestForPOSTWithUrl:urlStr parameter:parameter success:^(id responseObject) {
        if (REQUESTDATASUCCESS) {
            YXClassRoomModel *model = [YXClassRoomModel mj_objectWithKeyValues:responseObject[@"body"]];
            [self.contentView.picImage sd_setImageWithURL:[NSURL URLWithString:model.imghead] placeholderImage:[UIImage imageNamed:@""]];
            self.contentView.titleLab.text = model.name;
            self.contentView.contentLab.text = model.introduce;
            self.contentView.timeLab.text = [UILabel formateData:model.creatTime];
            [self.view addSubview:self.contentView];
        }
    } failure:^(NSError *error) {
        [self showAlertWithTitle:@"提示" Messge:@"维护中，请稍等！"];
    }];
}

@end
